<template>
    <div class="row">
      <div class="column">
        <h2 class="category">{{ title }}</h2>
        <div class="products">
          <div v-for="(item, index) in items" :key="index" class="product-item">
            <a :href="`/indProduct/${item.id}`" target="_blank">
              <div>
                <el-image :src="item.url" alt=""></el-image>
                <div class="details">
                  <span class="name">{{ item.name }}</span>
                  <span class="price">￥{{ item.price }}</span>
                </div>
              </div>
            </a>
          </div>
        </div>
      </div>
    </div>
  </template>

<script>
  export default {
    props: ['items', 'title']
  }
</script>
<style lang="less" scoped>
  .row {
    display: flex;
    justify-content: center;
  }

  .column {
    margin: 20px;
    width: 1200px;
  }

  .category {
    text-align: center;
  }

  .products {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
  }

  .product-item {
    margin: 10px;
    /* Calculate width: subtract the total margin space (left and right)
      from the 1/4th of the parent container. */
    /* You may have to adjust the values if you're providing padding or border. */
    width: calc(20% - 10px);
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 10px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
  }

  .product-item:hover {
    box-shadow: 0 0 10px rgb(221, 3, 3);
  }

  .product-item a {
    text-decoration: none;
    color: inherit;
  }

  .product-item img {
    width: 100%;
    height: auto;
    border-radius: 5px;
  }

  .details {
    margin-top: 10px;
    text-align: center;
    font-size: 25px;
  }

  .name {
    font-weight: bold;
  }

  .price {
    color: #ff0000;
  }
</style>
